var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var that = this
    var myDate = new Date()
    const Y = myDate.getFullYear() < 10 ? '0' + myDate.getFullYear() : myDate.getFullYear();
    const M = myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : (myDate.getMonth() + 1);
    const D = myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate();

    const h = myDate.getHours() < 10 ? '0' + myDate.getHours() : myDate.getHours(); //获取当前小时数(0-23)  
    const m = myDate.getMinutes() < 10 ? '0' + myDate.getMinutes() : myDate.getMinutes();
    const curDay = Y + '-' + M + '-' + D + ' ' + h + ':' + m;
    that.setData({
      cardNumber: options.cardNumber,
      time: curDay
    })
    console.log(that.data.cardNumber)
  },
  comfirm() {
    var that = this
    app.executeRequest(function (header) {
      wx.request({
        url: app.BASE_URL + '/hospitalized/getIcardDetailInfo',
        header: header,
        data: {
          cardNum: that.data.cardNumber,
        },
        success: (res) => {
          console.log(res)
          that.setData({
            phoneNumber: res.data.data.infos.cardOwner,
            isUser: res.data.data.isUser,
            cardNumber: res.data.data.infos.cardNum,
            address: res.data.data.infos.address,
            cardfee: res.data.data.infos.cardFee,
            hotline: res.data.data.infos.hotline,
            balance: res.data.data.infos.balance
          })
          console.log(that.data)
          wx.reLaunch({
            url: '../CardDetails/CardDetails?isUser=' + that.data.isUser + '&card=' + that.data.cardNumber + '&address=' + that.data.address + '&cardfee=' + that.data.cardfee + '&hotline=' + that.data.hotline + '&balance=' + that.data.balance,
          })
        }
      })
    })
  },
  gotoSelect() {
    var that = this
    wx.navigateTo({
      url: '../selectLease/selectLease?card=' + that.data.cardNumber
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})